Quiz: Object-oriented Basics

Test your basic OOP concepts explained in this chapter with a quiz.

We'll cover the following

Match the answers#

You're a game developer who's been tasked with developing some of the popular games such as tic-tac-toe, Sudoku, and so on. To define the requirements and implement an initial structure of your project, you decide to use object-oriented programming that helps in establishing relationships and visualizing them.

An example of how the structure of this project will be defined is given below:

The structure of OOP classes

Using the scenario given above, match the OOP principles in the left column with their correct examples from the right column.

Match The Answer
Select an option from the left-hand side

Encapsulation

Each game will have its specific way of making a move. Hence, the makeMove() function will be unique to each game.

Abstraction

The TicTacToe and Sudoku classes are able to use the public attributes and methods of the Game class.

Inheritance

Only interested in the makeMove() method, which simply performs the move and doesn’t go into the depth of how the move is being made.

Polymorphism

The method getPlayers(), getIsHuman(), and setValue() are examples of this principle.


MCQs#

Challenge yourself by solving the following quiz questions.

1

Which OOP principle describes reusability?

A)

Encapsulation

B)

Abstraction

C)

Inheritance

D)

Polymorphism

Question 1 of 50 attempted

Polymorphism

Introduction to Object-oriented Analysis and Design (OOAD)